using System;
using System.IO;

namespace DaphneTranslator.BusinessLogic
{
	public class XmlFileMapper: IMapper
	{
		public XmlFileMapper ()
		{
		}
		
		#region IMapper implementation
		
		public void ResolveFile (FileMapper mapper, string sRelativeFilePath)
		{
			string sFilename = Path.GetFileName (sRelativeFilePath);
			string[] arrParts = sFilename.Split (new string[] {"."}, StringSplitOptions.RemoveEmptyEntries);
			if (arrParts.Length > 0) {
				string sKeyName = arrParts [0];
				MappedFileCollection coll = mapper.GetCollectionByFileSubString (sKeyName);
				if (coll == null) {
					mapper.CreateNewCollection (sRelativeFilePath);
				} else {
					coll.Add (sRelativeFilePath);
				}
			}
		}
		#endregion
	}
}
